<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>反馈管理 - 应急防护小站</title>
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body class="bg-gray-50 min-h-screen text-gray-900">
    <!-- 顶部导航栏 -->
    <nav class="bg-white shadow-sm sticky top-0 z-40">
        <div class="max-w-7xl mx-auto flex items-center justify-between px-4 h-16">
            <div class="flex items-center space-x-2">
                <i class="fa-solid fa-shield-alt text-red-600 text-2xl"></i>
                <span class="text-xl font-bold">应急防护小站</span>
                <span class="text-sm text-gray-500 ml-2">反馈管理</span>
            </div>
            <div class="flex items-center space-x-4">
                <a href="admin-dashboard.jsp" class="text-gray-600 hover:text-red-600 flex items-center">
                    <i class="fa-solid fa-arrow-left mr-1"></i>返回管理中心
                </a>
                <a href="logout" class="text-gray-600 hover:text-red-600 flex items-center">
                    <i class="fa-solid fa-sign-out-alt mr-1"></i>退出登录
                </a>
            </div>
        </div>
    </nav>

    <!-- 主内容区 -->
    <main class="max-w-7xl mx-auto px-4 py-8">
        <!-- 页面标题 -->
        <div class="mb-8">
            <h1 class="text-3xl font-bold text-gray-900 mb-2">反馈管理</h1>
            <p class="text-gray-600">处理和管理用户反馈信息</p>
        </div>

        <!-- 错误信息显示 -->
        <c:if test="${not empty error}">
            <div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-6">
                <i class="fa-solid fa-exclamation-triangle mr-2"></i>
                ${error}
            </div>
        </c:if>

        <!-- 反馈统计 -->
        <div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-8">
            <div class="bg-white rounded-xl shadow p-6 border-l-4 border-blue-500">
                <div class="flex items-center justify-between">
                    <div>
                        <p class="text-gray-500 text-sm">总反馈数</p>
                        <p class="text-2xl font-bold text-gray-900">${feedbacks.size()}</p>
                    </div>
                    <i class="fa-solid fa-comment-dots text-blue-500 text-2xl"></i>
                </div>
            </div>
            <div class="bg-white rounded-xl shadow p-6 border-l-4 border-green-500">
                <div class="flex items-center justify-between">
                    <div>
                        <p class="text-gray-500 text-sm">已处理</p>
                        <p class="text-2xl font-bold text-gray-900">
                            <c:set var="processedCount" value="0"/>
                            <c:forEach var="feedback" items="${feedbacks}">
                                <c:if test="${feedback.status == 'processed'}">
                                    <c:set var="processedCount" value="${processedCount + 1}"/>
                                </c:if>
                            </c:forEach>
                            ${processedCount}
                        </p>
                    </div>
                    <i class="fa-solid fa-check-circle text-green-500 text-2xl"></i>
                </div>
            </div>
            <div class="bg-white rounded-xl shadow p-6 border-l-4 border-yellow-500">
                <div class="flex items-center justify-between">
                    <div>
                        <p class="text-gray-500 text-sm">待处理</p>
                        <p class="text-2xl font-bold text-gray-900">
                            <c:set var="pendingCount" value="0"/>
                            <c:forEach var="feedback" items="${feedbacks}">
                                <c:if test="${feedback.status == 'pending'}">
                                    <c:set var="pendingCount" value="${pendingCount + 1}"/>
                                </c:if>
                            </c:forEach>
                            ${pendingCount}
                        </p>
                    </div>
                    <i class="fa-solid fa-clock text-yellow-500 text-2xl"></i>
                </div>
            </div>
            <div class="bg-white rounded-xl shadow p-6 border-l-4 border-purple-500">
                <div class="flex items-center justify-between">
                    <div>
                        <p class="text-gray-500 text-sm">已回复</p>
                        <p class="text-2xl font-bold text-gray-900">
                            <c:set var="repliedCount" value="0"/>
                            <c:forEach var="feedback" items="${feedbacks}">
                                <c:if test="${not empty feedback.reply}">
                                    <c:set var="repliedCount" value="${repliedCount + 1}"/>
                                </c:if>
                            </c:forEach>
                            ${repliedCount}
                        </p>
                    </div>
                    <i class="fa-solid fa-reply text-purple-500 text-2xl"></i>
                </div>
            </div>
        </div>

        <!-- 反馈列表 -->
        <div class="bg-white rounded-xl shadow overflow-hidden">
            <div class="px-6 py-4 border-b border-gray-200">
                <h3 class="text-lg font-bold text-gray-900">反馈列表</h3>
            </div>
            <div class="overflow-x-auto">
                <table class="min-w-full divide-y divide-gray-200">
                    <thead class="bg-gray-50">
                        <tr>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                反馈ID
                            </th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                用户
                            </th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                反馈内容
                            </th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                提交时间
                            </th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                状态
                            </th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                回复
                            </th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                操作
                            </th>
                        </tr>
                    </thead>
                    <tbody class="bg-white divide-y divide-gray-200">
                        <c:forEach var="f" items="${feedbacks}">
                            <tr class="hover:bg-gray-50">
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
                                    #${f.id}
                                </td>
                                <td class="px-6 py-4 whitespace-nowrap">
                                    <div class="flex items-center">
                                        <div class="flex-shrink-0 h-10 w-10">
                                            <div class="h-10 w-10 rounded-full bg-gray-300 flex items-center justify-center">
                                                <i class="fa-solid fa-user text-gray-600"></i>
                                            </div>
                                        </div>
                                        <div class="ml-4">
                                            <div class="text-sm font-medium text-gray-900">
                                                ${f.username}
                                            </div>
                                            <div class="text-sm text-gray-500">
                                                ID: ${f.userId}
                                            </div>
                                        </div>
                                    </div>
                                </td>
                                <td class="px-6 py-4">
                                    <div class="text-sm text-gray-900">
                                        <c:choose>
                                            <c:when test="${fn:length(f.content) > 100}">
                                                ${fn:substring(f.content, 0, 100)}...
                                            </c:when>
                                            <c:otherwise>
                                                ${f.content}
                                            </c:otherwise>
                                        </c:choose>
                                    </div>
                                </td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
                                    <fmt:formatDate value="${f.createTime}" pattern="yyyy-MM-dd HH:mm"/>
                                </td>
                                <td class="px-6 py-4 whitespace-nowrap">
                                    <c:choose>
                                        <c:when test="${f.status == 'processed'}">
                                            <span class="inline-flex px-2 py-1 text-xs font-semibold rounded-full bg-green-100 text-green-800">
                                                已处理
                                            </span>
                                        </c:when>
                                        <c:when test="${f.status == 'pending'}">
                                            <span class="inline-flex px-2 py-1 text-xs font-semibold rounded-full bg-yellow-100 text-yellow-800">
                                                待处理
                                            </span>
                                        </c:when>
                                        <c:otherwise>
                                            <span class="inline-flex px-2 py-1 text-xs font-semibold rounded-full bg-gray-100 text-gray-800">
                                                ${f.status}
                                            </span>
                                        </c:otherwise>
                                    </c:choose>
                                </td>
                                <td class="px-6 py-4">
                                    <c:if test="${not empty f.reply}">
                                        <div class="text-sm text-gray-900">
                                            <c:choose>
                                                <c:when test="${fn:length(f.reply) > 50}">
                                                    ${fn:substring(f.reply, 0, 50)}...
                                                </c:when>
                                                <c:otherwise>
                                                    ${f.reply}
                                                </c:otherwise>
                                            </c:choose>
                                        </div>
                                        <div class="text-xs text-gray-500">
                                            <fmt:formatDate value="${f.replyTime}" pattern="yyyy-MM-dd HH:mm"/>
                                        </div>
                                    </c:if>
                                    <c:if test="${empty f.reply}">
                                        <span class="text-gray-400 text-sm">暂无回复</span>
                                    </c:if>
                                </td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
                                    <div class="flex space-x-2">
                                        <button class="text-blue-600 hover:text-blue-900" title="查看详情">
                                            <i class="fa-solid fa-eye"></i>
                                        </button>
                                        <c:if test="${f.status == 'pending'}">
                                            <button class="text-green-600 hover:text-green-900" title="标记已处理">
                                                <i class="fa-solid fa-check"></i>
                                            </button>
                                        </c:if>
                                        <button class="text-yellow-600 hover:text-yellow-900" title="回复">
                                            <i class="fa-solid fa-reply"></i>
                                        </button>
                                        <button class="text-red-600 hover:text-red-900" title="删除">
                                            <i class="fa-solid fa-trash"></i>
                                        </button>
                                    </div>
                                </td>
                            </tr>
                        </c:forEach>
                    </tbody>
                </table>
            </div>
        </div>
    </main>

    <!-- 底部信息 -->
    <footer class="bg-gray-900 text-white py-8 mt-16">
        <div class="max-w-7xl mx-auto px-4 text-center">
            <div class="flex items-center justify-center space-x-2 mb-4">
                <i class="fa-solid fa-shield-alt text-red-400 text-xl"></i>
                <span class="text-lg font-bold">应急防护小站管理中心</span>
            </div>
            <p class="text-gray-400 text-sm">&copy; 2025 应急防护小站. 保留所有权利.</p>
        </div>
    </footer>
</body>
</html> 